package com.partners.controller;

import com.partners.annotation.SimpleParam;
import com.partners.constant.ErrorMessageEnum;
import com.partners.model.ApiResult;
import com.partners.service.FansService;
import com.partners.utils.ApiResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * 粉丝管理
 * @author liangyongle
 * @date 2018-12-05
 */
@RequestMapping("fans")
@RestController
@Slf4j
public class FansController {

    @Resource
    private FansService fansService;


    @PostMapping("fansInfo")
    public ApiResult getFansInfo(@SimpleParam("openId") String openId){
        Object fansInfo = fansService.getFansInfoByOpenId(openId);
        if(fansInfo == null){
            return ApiResultUtil.failure(ErrorMessageEnum.FANS_NOT_FOUND);
        }
        return ApiResultUtil.ok(fansInfo);
    }

    @RequestMapping("news")
    public ApiResult newFans(HttpSession session){
        return ApiResultUtil.ok("asdas"
        );
    }

}
